package view
{
	import com.bit101.components.VBox;
	
	import component.LContainer;
	
	import flash.display.Bitmap;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class ItemDetails extends LContainer
	{
		public var p:VBox;
		public function ItemDetails(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0)
		{
			super(parent, xpos, ypos);
			init();
		}
		public function setchild(child:Sprite):void{
			p = VBox(child)
			this.addChild(p);
			this.x = 12;
			
			if(p.height > 323){
				this.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
			}
			p.addEventListener("resizeevent",resize);
		}
		private function init():void{
			this.width = 160;
			this.height = 323;
		}
		private function resize(event:Event):void{
			if(p.height > 323){
				this.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
			}else{
				this.removeEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
			}
		}
		private function onMouseMove(event:MouseEvent):void{
			var by:Number = (p.height - 320) * 0.5;
			p.y = -2 * by * this.mouseY / 320;
		}
	}
}